package com.meetme.android.multistateview;

import android.graphics.drawable.GradientDrawable;

/**
 * @author 黄赛赛
 * @version V1.0
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}()
 * @date 2016/5/16 22:07
 */
public class ShapeFactory {

    /**
     *
     * @param fillColor
     * @param strokeWidth
     * @param strokeColor
     * @param cornerRadius
     * @return
     */
    public GradientDrawable getStokeRoundRectangle(int fillColor, int strokeWidth, int strokeColor, float cornerRadius){
        GradientDrawable shape = new GradientDrawable();
        shape.setColor(fillColor);
        if (cornerRadius > 0){
            shape.setCornerRadius(cornerRadius);
        }
        if (strokeWidth > 0){
            shape.setStroke(strokeWidth,strokeColor);
        }
        return shape;
    }


    /**
     *
     * @param fillColor
     * @param strokeWidth
     * @param strokeColor
     * @param cornerRadius
     * @param direction  1  left  2  top 3 right  4 bottom
     * contains 2 values, <code>[X_radius, Y_radius]</code>. The corners are ordered
     * top-left, top-right, bottom-right, bottom-left. This property
     * @return
     */
    public GradientDrawable getDirectionRoundRectangle(int fillColor, int strokeWidth, int strokeColor, float cornerRadius, int direction){
        GradientDrawable shape = new GradientDrawable();
        shape.setColor(fillColor);

        switch (direction){
                case 1:
                    shape.setCornerRadii(new float[]{cornerRadius, cornerRadius, 0,0,0,0,cornerRadius,cornerRadius,});
                break;
                case 2:
                    shape.setCornerRadii(new float[]{cornerRadius, cornerRadius,cornerRadius,cornerRadius, 0,0,0,0,});
                    break;
                case 3:
                    shape.setCornerRadii(new float[]{0, 0,cornerRadius, cornerRadius,cornerRadius, cornerRadius,0,0});
                    break;
                case 4:
                    shape.setCornerRadii(new float[]{0, 0, 0,0,cornerRadius, cornerRadius,cornerRadius,cornerRadius,});

                    break;

        }
        if (strokeWidth > 0){
            shape.setStroke(strokeWidth,strokeColor);
        }
        return shape;
    }

}
